<?php
class Admin_UsersController extends Zend_Controller_Action
{
	public function indexAction()
	{
		$this->_helper->layout->disableLayout();
		if (Mage::getSingleton('application/users')->isLoggedIn()) {
		    $this->_redirect('admin');
		}
//		$flashMessenger = $this->_helper->FlashMessenger(null);
//		if ($flashMessenger->setnamespace('error')->hasmessages()) {
//            foreach ($flashMessenger->getmessages() as $msg) {
//                echo $msg;
//            }
//            exit;
//		}
		//$this->view->message = $message;
	}

	public function loginAction()
	{
	    $request = $this->getRequest();
		$username = addslashes($request->getParam('username'));
		$password = $request->getParam('password');
		$user = Mage::getSingleton('application/users');
		$user->login($username, $password);
		if ($user->isLoggedIn()) {
            $this->_redirect('admin/catalog');
		} else {
            $this->_redirect('admin/users');
		}
	}

    public function logoutAction()
	{
		Mage::getSingleton('application/users')->logout();
		$this->_redirect('admin/users');
	}
}

